package com.crawler.dto;

import java.text.ParseException;

import com.google.common.base.Strings;

public class Parameter {
    private String eticketNoORIn;
    private String passengerName;
    private String randCode;
    private String content;
    private Exception exc;
    private int unusedCount = 0;// 未使用记录数
    private int useCount = 0;// 已使用记录数
    @SuppressWarnings("unused")
    private State state;// 状态
    private ProcessingTime processingtime;
    private boolean randCodeState = true;// 验证码请求状态 false 失败 true 成功

    public boolean isRandCodeState() {
        return randCodeState;
    }

    public Parameter() {
        super();
    }

    public void setRandCodeState(boolean randCodeState) {
        this.randCodeState = randCodeState;
    }

    public Parameter(String eticketNoORIn, String passengerName, String scheduledTime) {
        super();
        this.eticketNoORIn = eticketNoORIn;
        this.passengerName = passengerName;
        processingtime = new ProcessingTime(scheduledTime);
    }

    /**
     * 
     * 方法描述：日期是否超出当前时间
     * 
     * @author TL
     * @date 2016年6月20日 下午9:05:10
     * @param date
     * @return
     * @throws ParseException
     */
    public boolean comparingDate(String date) throws ParseException {
        return processingtime.comparingDate(date);
    }

    /**
     * 
     * 方法描述：统计状态
     * 
     * @author TL
     * @date 2016年6月20日 下午9:23:59
     * @param str
     */
    public void stateStatistical(String str) {
        if (!Strings.isNullOrEmpty(str))
            unusedCount++;
        else
            useCount++;
    }

    public int getUnusedCount() {
        return unusedCount;
    }

    public void setUnusedCount(int unusedCount) {
        this.unusedCount = unusedCount;
    }

    public int getUseCount() {
        return useCount;
    }

    public void setUseCount(int useCount) {
        this.useCount = useCount;
    }

    public State getState() {
        if (useCount > 0 && unusedCount > 0)
            return State.partUnused;
        else if (useCount > 0 && unusedCount == 0)
            return State.allUse;
        else if (useCount == 0 && unusedCount > 0)
            return State.allUnused;
        return State.allUse;
    }

    public Exception getExc() {
        return exc;
    }

    public void setExc(Exception exc) {
        this.exc = exc;
    }

    public String getEticketNoORIn() {
        return eticketNoORIn;
    }

    public void setEticketNoORIn(String eticketNoORIn) {
        this.eticketNoORIn = eticketNoORIn;
    }

    public String getPassengerName() {
        return passengerName;
    }

    public void setPassengerName(String passengerName) {
        this.passengerName = passengerName;
    }

    public String getRandCode() {
        return randCode;
    }

    public void setRandCode(String randCode) {
        this.randCode = randCode;
    }

    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    }

    @Override
    public String toString() {
        return "Parameter [eticketNoORIn=" + eticketNoORIn + ", passengerName=" + passengerName + ", randCode="
                + randCode + ", content=" + content + ", exc=" + exc + ", unusedCount=" + unusedCount + ", useCount="
                + useCount + ", state=" + getState() + ", processingtime=" + processingtime + ", randCodeState="
                + randCodeState + "]";
    }

}
